import { Component, ElementRef, OnInit, Input, ViewChild, Output, EventEmitter, AfterViewInit } from '@angular/core';

import { Service } from '../../../server/server';
import { CudTableService } from '../../../public/serve/cud-table/cud-table.service';
import { RemoveTableService } from '../../../public/serve/remove-table/remove-table.service';
declare var $: any;


@Component({
  selector: 'app-database-detele',
  templateUrl: './database-detele.component.html'
})
export class DatabaseDeteleComponent implements OnInit {

  constructor(private server: Service, private tableListService: CudTableService, private removeTableService: RemoveTableService) { }

  ngOnInit() {
  }

  @Output()
  deleteOutput: EventEmitter<string> = new EventEmitter();

  delete() {
    let url = this.server.baseUrl + 'Service/TalbesService/delect';
    this.removeTableService.confirmRemove("tableId", url).then((res: any) => {
      this.deleteOutput.emit(res.result_code);
      $("#delete").modal("hide");
      if (res.result_code == '0000') {
        this.server.prompt = { prompt: true, success: true, fail: false, promptStatement: res.message }
        this.server.promptclose;

      } else {
        this.server.prompt = { prompt: true, success: false, fail: true, promptStatement: res.message }
        this.server.promptclose;
      }
    }).catch()
  }
}
